import 'package:easy_read_comic/internal/http_client.dart';
import 'package:get/get.dart';

import '../../models/comic_model.dart';
import '../../models/navigate_model.dart';

class IndexListController extends GetxController {
  List<ComicModel> list = [];

  final NavigateModel navigate;

  IndexListController(this.navigate);

  @override
  void onInit() {
    print(this.navigate.Id);
    super.onInit();
    this.getList();
  }
  @override
  void onClose() {
    super.onClose();
  }

  void getList() {
    HttpClient().get("/v1/comic/list", queryParameters: {
      "navigate_id": this.navigate.Id,
    }).then((response) {
      for (var item in response.data["data"]["List"]) {
        this.list.add(ComicModel.formJson(item));
      }
      this.update();
    });
  }
}
